package com.xydtech.ecard.custgroup.service.impl;

import com.xydtech.common.annotation.DataScope;
import com.xydtech.common.core.domain.entity.SysDept;
import com.xydtech.common.core.text.Convert;
import com.xydtech.common.utils.ShiroUtils;
import com.xydtech.ecard.custgroup.domain.EcardCustomerGroupInfo;
import com.xydtech.ecard.custgroup.mapper.EcardCustomerGroupInfoMapper;
import com.xydtech.ecard.custgroup.service.IEcardCustomerGroupInfoService;
import com.xydtech.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 行业客户配置Service业务层处理
 *
 * @author yuzhiguo
 * @date 2024-11-26 下午1:28
 */
@Service("customerGroupInfo")
public class EcardCustomerGroupInfoServiceImpl implements IEcardCustomerGroupInfoService
{
    @Autowired
    private EcardCustomerGroupInfoMapper ecardCustomerGroupInfoMapper;
    @Autowired
    private ISysDeptService sysDeptService;

    /**
     * 查询行业客户配置
     *
     * @param id 行业客户配置主键
     * @return 行业客户配置
     */
    @Override
    public EcardCustomerGroupInfo selectEcardCustomerGroupInfoById(Long id)
    {
        return ecardCustomerGroupInfoMapper.selectEcardCustomerGroupInfoById(id);
    }

    /**
     * 查询行业客户配置列表
     *
     * @param ecardCustomerGroupInfo 行业客户配置
     * @return 行业客户配置
     */
    @Override
    @DataScope(userAlias = "u", deptAlias = "d")
    public List<EcardCustomerGroupInfo> selectEcardCustomerGroupInfoList(EcardCustomerGroupInfo ecardCustomerGroupInfo)
    {
        return ecardCustomerGroupInfoMapper.selectEcardCustomerGroupInfoList(ecardCustomerGroupInfo);
    }

    /**
     * 新增行业客户配置
     *
     * @param ecardCustomerGroupInfo 行业客户配置
     * @return 结果
     */
    @Override
    public int insertEcardCustomerGroupInfo(EcardCustomerGroupInfo ecardCustomerGroupInfo)
    {
        return ecardCustomerGroupInfoMapper.insertEcardCustomerGroupInfo(ecardCustomerGroupInfo);
    }

    /**
     * 修改行业客户配置
     *
     * @param ecardCustomerGroupInfo 行业客户配置
     * @return 结果
     */
    @Override
    public int updateEcardCustomerGroupInfo(EcardCustomerGroupInfo ecardCustomerGroupInfo)
    {
        return ecardCustomerGroupInfoMapper.updateEcardCustomerGroupInfo(ecardCustomerGroupInfo);
    }

    /**
     * 批量删除行业客户配置
     *
     * @param ids 需要删除的行业客户配置主键
     * @return 结果
     */
    @Override
    public int deleteEcardCustomerGroupInfoByIds(String ids)
    {
        return ecardCustomerGroupInfoMapper.deleteEcardCustomerGroupInfoByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除行业客户配置信息
     *
     * @param id 行业客户配置主键
     * @return 结果
     */
    @Override
    public int deleteEcardCustomerGroupInfoById(Long id)
    {
        return ecardCustomerGroupInfoMapper.deleteEcardCustomerGroupInfoById(id);
    }

    /**
     * 查询行业客户配置列表（页面筛选条件用）
     * @return
     */
    @Override
    public List<EcardCustomerGroupInfo> selectEcardCustomerGroupInfo() {
        SysDept sysDept = sysDeptService.selectSecondLevelDeptByDeptId(ShiroUtils.getSysUser().getDeptId());
        EcardCustomerGroupInfo customerGroup = new EcardCustomerGroupInfo();
        customerGroup.setDeptId(sysDept.getDeptId());
        return ecardCustomerGroupInfoMapper.selectEcardCustomerGroupInfoList(customerGroup);
    }
}
